package day20171109;

import java.io.*;

public class TestFile {
    public static void main(String[] args) {
        /*try
        {
            FileInputStream fr=new FileInputStream("D:\\dev\\sctu-java-2017-1\\1606101026张承财\\src\\lab02\\test02\\Roundness.java");
            InputStreamReader af=new InputStreamReader(fr, "UTF-8");
            BufferedReader bf=new BufferedReader(af);


            FileOutputStream fo=new FileOutputStream("D:\\新建 Microsoft Word 文档.docx");
            OutputStreamWriter osw=new OutputStreamWriter(fo);
            BufferedWriter bw=new BufferedWriter(osw);

            String line=bf.readLine();
            while(line!=null)
            {
                System.out.println(line);
                bw.write(line);
                bw.newLine();
                bw.flush();
                line=bf.readLine();
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }*/



        String source="D:\\KuGou\\Jam - 七月上.mp3";
        String target="F:\\七月上.mp3";

        //使用字节流来读写文件

        FileInputStream fileInputStream=null;
        FileOutputStream fileOutputStream=null;

        try {
            fileInputStream= new FileInputStream(source);
            fileOutputStream=new FileOutputStream(target);

            int data;

            //读一个字节，马上就写一个字节
            while ((data=fileInputStream.read())!=-1){
                    fileOutputStream.write(data);

            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {

            try {
                fileInputStream.close();
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
